package com.legrand.www.module.core.util;

public class MyThreadLocal {
    public static Integer a=22;
    public static final ThreadLocal<Object> threadLocal = new ThreadLocal<Object>() {
        /**
         * ThreadLocal没有被当前线程赋值时或当前线程刚调用remove方法后调用get方法，返回此方法值
         */
        @Override
        protected Object initialValue() {
            System.out.println("调用get方法时，当前线程共享变量没有设置，调用initialValue获取默认值！");
            return a;
        }
    };

    public static int getnCount() {
        return a;
    }
    public  static synchronized void setnCount(int a) {
        MyThreadLocal.a = a;
    }
}
